package com.sh.data.engine.application.model.request.integration;

import com.sh.data.engine.common.annotation.EnumValue;
import com.sh.data.engine.common.enumDefinition.DSType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.util.Date;

/**
 * @author: mengzheng.mhc
 * @date: 2024/6/4 17:50
 */
@Data
@Schema
public class DataSourceSaveRequest {

    private Long id;

    /**
     * 名称
     */
    @Schema(description = "数据源名称")
    @NotBlank(message = "数据源名称不能为空")
    @Length(min = 2, max = 32, message = "数据源名称长度在2-32个字符")
    @Pattern(regexp = "[a-zA-Z0-9_\\u4e00-\\u9fa5]+", message = "数据源名称支持中文、字母、数字和下划线")
    private String dsName;

    /**
     * 数据源类型
     */
    @Schema(description = "数据源类型")
    @NotBlank(message = "数据源类型不能为空")
    @EnumValue(enumClass = DSType.class, enumMethod = "isValidDSType", message = "数据源类型值不匹配")
    private String dsType;

    /**
     * 链接地址
     */
    @Schema(description = "链接地址")
    private String dsLink;

    /**
     * 描述
     */
    @Length(max = 128, message = "描述不要超过128个字符")
    private String dsDesc;

    @Schema(description = "连接属性")
    private String connectionProperty;

    private Date createTime;
    private String creatorId;
    private Date updateTime;
    private String updaterId;
}
